﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace PhoneApp1
{
    public partial class MainPage : PhoneApplicationPage
    {
        // 构造函数
        public MainPage()
        {
            InitializeComponent();
            this.Loaded += MainPage_Loaded;
            
        }

        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            DrewItem();
        }
        GameBase gb;

        private void DrewItem()
        {
            //Rectangle rect = new Rectangle();
            //rect.Width = 30;
            //rect.Height = 40;
            //rect.Fill = new SolidColorBrush(Colors.Red);
            //Canvas.SetLeft(rect, 10);
            //Canvas.SetTop(rect, 10);
            //ContentPanel.Children.Add(rect);
            //TowerItem t = new TowerItem(ContentPanel);
            gb = new GameBase(ContentPanel);
            gb.Init();
            ContentPanel.MouseLeftButtonDown += ContentPanel_MouseLeftButtonDown;
            ContentPanel.MouseLeftButtonUp += ContentPanel_MouseLeftButtonUp;
            this.DataContext = gb;

        }

        void ContentPanel_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (gb.SelectedItem != null)
                gb.SelectedItem.SetNoSelected();
        }

        void ContentPanel_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (1 == 1)
                Console.Write("as");
        }
    }
}